<template>
	<view class="newCar-page" :style="'background-color:' + pageBackgroundColor + ';'">
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block slot="backText"></block>
			<block slot="content">
				<text class="nav-title">{{Name}}</text>
			</block>
		</cu-custom>
		<view> 
			<view v-for="(item, index) in List" :key="index">
				<u-index-anchor :index="item.name" />
				<view class="cell" v-for="items in item.children" @click="openInfo(items)">
					<view class="label">{{items.name}}</view>
					<view class="right">
						{{items.number}}<u-icon name="arrow-right" ></u-icon>
					</view>
				</view>
			</view> 
		</view>
	</view>
	</view>
</template>

<script>
	import cuCustom from "@/components/custom-nav/cu-custom.vue";
	import addressSearchFixed from "@/components/addressSearch/addressSearchFixed.vue";
	import {
		newsGetList
	} from '@/api/card.js'
	export default {
		components: {
			cuCustom,
			addressSearchFixed
		},
		data() {
			return {
				Name:'',
				brand_id:'',//上级id
				scrollTop: 0,
				indexList: [],
				cardList: [],
				customNavTitleIndex: 1, // 页面标题下标
				pageBackgroundColor: '#FFFFFF', // 页面背景颜色
				sreachContent: '', //寻车列表中搜索框的功能
				List:[],
			}
		},

		onShow() {
			const value = uni.getStorageSync('newEnergName');
			this.Name = value
			try {
				// this.$utils.stopPage(); //禁止页面本身的滑动
				this.$refs.setAddres.setAddres()
			} catch (e) {
				//TODO handle the exception
			}

		},
		
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onHide() {
			this.$utils.movePage()
		},
		onUnload() {
			this.$utils.movePage()
		},
		onLoad(e) {
			this.brand_id = e.id
			console.log(this.id)
			this.getList()
		},
		methods: {
			openInfo(val){
				console.log(val)
				uni.navigateTo({
					url:'/pages/home/newCar/newEnergy/newEnergylist?id='+val.id
				})
				uni.setStorage({
					key:'newEnergName',
					data:val.name,
					success: function () {
						console.log('success');
					}
				});
			},
			getList(){
				let userId=getApp().globalData.user_id
				let data = {
					users_id:userId,
					brand_id:this.brand_id
				}
				console.log(data)
				newsGetList(data).then(res => {
					console.log(res.data)
					this.List = res.data
				})
			},
			// async getList() {
			// 	console.log();
			// 	let userId=getApp().globalData.user_id
				
			// 	const res = await getList(userId)
			// 	if (res.code == 0) {
			// 		this.cardList = res.data
			// 		for (let i = 0; i < res.data.length; i++) {
			// 			this.indexList[i] = res.data[i].code
			// 		}
			// 	}
			// },
			select(data) {
				console.log(data)
			},
			evFunc(data) {
				console.log(data)
			},
			clickData(data) {
				console.log(data);
			},

			// 点击——新车
			event_clickNewCarTitle() {
				this.$utils.log("新车")
				this.currentTitle = '新车'
			},
			// 点击——寻车
			event_clickSeachCarTitle() {
				this.$utils.log("寻车")
				this.currentTitle = '寻车'
			},
			// 点击——搜索框搜索按钮
			event_clickSearchBtn(content) {
				this.sreachContent = content
				this.$utils.log("点击搜索" + content)
				if (this.customNavTitleIndex == 2) {
					const loaction = uni.getStorageSync('address')
				} else {
					const loaction = uni.getStorageSync('address')
				}
			},


		}
	}
</script>

<style>
	.cell {
		display: flex;
		justify-content: space-between;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
	}

	.newCar-page {
		display: flex;
		flex-direction: column;
		width: 100%;
		height: auto;
	}

	.newCar-page .newCar-page__content {
		height: 100vh;
		/* 父元素设置相对定位 */
		position: relative;
		/* background-color: #F7F8FA; */
		background-color: #FFFFFF;
		padding: 26rpx 28rpx 0 28rpx;
	}

	/* 车系列表 */
	.carSeries-list {
		display: flex;
	}

	.carSeries-list__left {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.carSeries-list__right {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;

		margin-left: 14rpx;
	}

	/* 车系卡片 */
	.carSeries-card {
		border-radius: 10px;
		background-color: #FFFFFF;
		width: 100%;
		flex: 1;
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.carSeries-card__text {
		display: flex;
		flex-direction: column;
		margin-left: 30rpx;
	}

	.carSeries-card__text .title {
		font-family: Source Han Sans CN;
		font-weight: bold;
		font-size: 14px;
		text-align: left;
	}

	.carSeries-card__text .desc {
		margin-top: 5px;
		text-align: left;
		font: Alimama ShuHeiTi;
		font-size: 12px;
		color: #666666;
	}

	.carSeries-card__image {
		width: 58rpx;
		height: 50rpx;
		margin: 39rpx 50rpx 39rpx auto;
	}

	/* 常用车品牌列表 */
	.carCommonBrand-list {
		text-align: left;
		background-color: #FFFFFF;
		/* margin: 0px 14px 0px 14px; */
		border-radius: 10px;
		padding: 28rpx;
	}

	.carCommonBrand-list__title-background {
		width: 75px;
		background: url(@/static/bac-small.png);
		background-size: 100% 100%;
	}

	.carCommonBrand-list__title {
		width: 140rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #000026;
		opacity: 1;
		margin-left: 2rpx;
	}

	.carCommonBrand-list__content {
		display: flex;
		justify-content: center;
		padding: 37rpx 0 9rpx 0;
	}

	/* 车品牌 */
	.carBrand {
		flex: 1;
		width: 140rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.carBrand__image {
		height: 56rpx;
		width: 56rpx;
	}

	.carBrand__name {
		margin-top: 28rpx;

		font-size: 28rpx;
		font-weight: bold;
	}

	/* 车品牌索引列表 */
	.newCar-indexed-list__title-wrapper {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		padding: 6px 0px 4px 14px;
	}

	.newCar-indexed-list__title {
		font-size: 28rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #1C2125;
		opacity: 1;
	}

	.newCar-indexed-list__menu {
		display: flex;
		position: fixed;

		top: 50%;
		right: 0;
		-webkit-transform: translate(-50%, -50%);
		transform: translate(0, -50%);

		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.nav-title {
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		line-height: 0rpx;
		color: #FFFFFF;
		opacity: 1;
		margin-left: 20rpx;
		margin-right: 20rpx;
	}

	.nav-title-selected {
		font-family: Alimama ShuHeiTi;
		font-weight: bold;
	}

	.content-row {
		display: flex;
		flex-direction: row;
		align-items: center;
	}


	.pad18-14 {
		padding: 18rpx 28rpx;
	}

	.pad6-14-4 {
		padding: 6px 0px 4px 14px;
	}

	.iamge-class {
		width: 100rpx;
		height: 52rpx;
	}

	.marginLeft5 {
		margin-left: 5px;
	}

	.brand-name-class {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #000026;
		opacity: 1;
	}

	.right-view-text {
		font-size: 20rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #999999;
		padding: 4rpx;
	}

	.right-view-text-select {
		font-size: 20rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #0E59EA;
		padding: 4rpx;
	}
</style>